<?php
/**
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       Cake.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

$cakeDescription = __d('cake_dev', 'FAPES: Administradora de Benefícios');
//echo $this->Html->meta()
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php echo $this->Html->charset(); ?>
	<title>
		<?php echo $cakeDescription ?>:
		<?php echo $title_for_layout; ?>
	</title>
	<?php
		echo $this->Html->meta('favicon.ico', $this->webroot.'img/favicon.ico', array('type' => 'icon'));

		echo $this->Html->css('cake.generic');
		echo $this->Html->css('jquery-ui');
		echo $this->Html->css('jsDatePick_ltr.min');
		echo $this->Html->script('jsDatePick.min.1.3');
		echo $this->Html->script('jquery-latest');
		echo $this->Html->script('jquery-1.9.1');
		echo $this->Html->script('jquery-ui');
		echo $this->Html->script('ckeditor/ckeditor');
		echo $this->Html->script('jquery.maskedinput');
		

		echo $this->fetch('meta');
		echo $this->fetch('css');
		echo $this->fetch('script');
	?>

</head>
<body>
	<div id="container">
		<div id="header">
			<!--  <h1><?php //echo $this->Html->link($cakeDescription, 'http://cakephp.org'); ?></h1>-->
			<div style=" width: 100%; height: 100%; display: table;">
				<div style="float: left; position:relative; width: 800px;">
					<?php echo $this->Html->link(
							$this->Html->image('logo.png', array('alt' => $cakeDescription, 'border' => '0')),
							'http://www.prevquali.com.br/site/', array('target' => '_blank', 'escape' => false));
					?>
				</div>
				<div id="logo-repeat" class="logo-repeat" style="float: left; position:relative; height: 147px;">
				</div>
			</div>
			
			<div id="sair">
				<?php
					$id = CakeSession::read("Auth.User.id");
					$nome = CakeSession::read("Auth.User.nome");
				
					if($id) { 	
						echo "Bem-vindo: ".$nome."     ";
					
						echo $this->Html->link('Sair', array('controller' => 'users', 'action' => 'logout'));
					}
					
					//$user = $this->Session->read('User')
				?>
				
			</div>
			
		</div>
		
		
		<div id="content">

			<?php echo $this->Session->flash(); ?>
			<?php echo $this->Session->flash('auth'); ?>
			
			<?php echo $this->fetch('content'); ?>
		</div>
		<div id="footer">
			<?php /*echo $this->Html->link(
					$this->Html->image('cake.power.gif', array('alt' => $cakeDescription, 'border' => '0')),
					'http://www.cakephp.org/',
					array('target' => '_blank', 'escape' => false)
				);*/
				 echo "© 2013 Prevquali TI. Todos os direitos reservados."
			?>
		</div>
	</div>
	<?php echo $this->element('sql_dump'); ?>
</body>

<!-- script para funcionamento  accordion menu -->
<SCRIPT type="text/javascript">
$("#accordion > li").click(function(){

	if(false == $(this).next().is(':visible')) {
		$('#accordion > ul').slideUp(300);
	}
	$(this).next().slideToggle(300);
});

//$('#accordion > ul:eq(0)').show();


$(function(){
			$('.datepick').datepicker({
				inline: true,
				nextText: 'Próximo',
				prevText: 'Anterior',
				showOtherMonths: true,
				dateFormat: 'dd/mm/yy',
				dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],
    			dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
				monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
				monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
				//showOn: "button",
				//buttonImage: "img/calendar-blue.png",
				//buttonImageOnly: true,
			});

			

			document.getElementById('logo-repeat').style.width = ((($(window).width()-820)/$(window).width())*100)+'%';

			/* ------- data picker ----------- */
			/*new JsDatePick({
				useMode:2,
				target:"startdatecliente",
				dateFormat:"%d/%m/%Y",
				/*selectedDate:{				This is an example of what the full configuration offers.
					day:5,						For full documentation about these settings please see the full version of the code.
					month:9,
					year:2006
				},*/
				//yearsRange:[1952,2013],
				/*limitToToday:true,
				cellColorScheme:"ocean_green",
				//dateFormat:"%m-%d-%Y",
				imgPath:<?php echo $this->webroot; ?> + "img/datapicker/",
				weekStartDay:0
			});

			 new JsDatePick({
				useMode:2,
				target:"enddatecliente",
				dateFormat:"%d/%m/%Y",
				/*selectedDate:{				This is an example of what the full configuration offers.
					day:5,						For full documentation about these settings please see the full version of the code.
					month:9,
					year:2006
				},*/
			//	yearsRange:[1952,2013],
				/*limitToToday:true,
				cellColorScheme:"ocean_blue",
				//dateFormat:"%m-%d-%Y",
				imgPath:<?php echo $this->webroot; ?> + "img/datapicker/",
				weekStartDay:0
			});*/

			$("input.cpfsearchcliente").mask("999.999.999-99");
			
		});

function validateTemTaxa(input){
	if(input.checked == 1) {
		document.getElementById('op_div_textofaixa').disabled=false;
		document.getElementById('op_div_textofaixa').style.backgroundColor = '#FFFFFF';
	} else {
		document.getElementById('op_div_textofaixa').disabled=true;
		document.getElementById('op_div_textofaixa').style.backgroundColor = '#D3D3D3';
		document.getElementById('op_div_textofaixa').value = '';
	}
}

function mostrarOdont(input){
	if(input.checked == 1) {
		document.getElementById('OperadoraOperadoraodontId').disabled=false;
		//alert("Teste");
	} else {
		document.getElementById('OperadoraOperadoraodontId').selectedIndex = 0;
		document.getElementById('OperadoraOperadoraodontId').disabled=true;
	}
}

function mostrarSeguro(input){
	if(input.checked == 1) {
		document.getElementById('OperadoraSegurovidaId').disabled=false;
		//alert("Teste");
	} else {
		document.getElementById('OperadoraSegurovidaId').selectedIndex = 0;
		document.getElementById('OperadoraSegurovidaId').disabled=true;
	}
}

function validarSeguradora(input){
	if(input.selectedIndex == 1) {
		document.getElementById('SegurovidaSeguro1Id').disabled=false;
		document.getElementById('SegurovidaSeguro2Id').disabled=false;
		
		document.getElementById('SegurovidaArquivo').disabled=false;
		
	} else if(input.selectedIndex == 0 | input.selectedIndex == 2 | input.selectedIndex == 3) {
		document.getElementById('SegurovidaSeguro1Id').disabled=true;
		document.getElementById('SegurovidaSeguro2Id').disabled=true;
		
		document.getElementById('SegurovidaSeguro1Id').selectedIndex=0;
		document.getElementById('SegurovidaSeguro2Id').selectedIndex=0;
		
		document.getElementById('SegurovidaArquivo').disabled=true;
		
	}
}

function disableElements(input) {
	
	var nodes = input.getElementsByTagName('*');
	//alert("teste: "+nodes.length);
	for(var i = 0; i < nodes.length; i++) {
	     nodes[i].disabled = true;
	}
}

function enableElements(input) {
	var nodes = input.getElementsByTagName('*');
	for(var i = 0; i < nodes.length; i++) {
	     nodes[i].disabled = false;
	}
}

function validateOrgao(){
	var e = document.getElementById('ClienteOrgaoId');
	var stringOption = e.options[e.selectedIndex].text;
	if(stringOption == 'Outros') {
		document.getElementById('op_div_orgao').disabled=false;
		document.getElementById('op_div_orgao').style.backgroundColor = '#FFFFFF';
	} else {
		document.getElementById('op_div_orgao').disabled=true;
		document.getElementById('op_div_orgao').style.backgroundColor = '#D3D3D3';
		document.getElementById('op_div_orgao').value = '';
	}
}

function validateDateSearch() {

	var startdate = document.getElementById('startdate').value;
	var enddate = document.getElementById('enddate').value;
	
    startdate = startdate.replace(/(\d+)\/(\d+)\/(\d+)/, "$3/$2/$1");
    enddate = enddate.replace(/(\d+)\/(\d+)\/(\d+)/, "$3/$2/$1");
    var sdate = new Date(startdate);
    var edate = new Date(enddate);
	
	//alert("teste");

	if(sdate > edate) {
		alert("Atenção! A data inicial deve ser menor que a data final para a buscar poder ser realizada.");
		return false;
	}

	return true;
}

function setTargetBlank() {
	
	document.getElementById('formFilterPrev').target = '_blank';
}

function setTargetSelf() {
	
	document.getElementById('formFilterPrev').target = '_self';
}

function validateclearSearch() {

	alert("teste");
	document.getElementById('conferidocliente').selectedIndex = 0;	
	document.getElementById('startdatecliente').value = '';
	document.getElementById('enddatecliente').value = '';
	document.getElementById('ClienteUfId').selectedIndex = 0;
	document.getElementById('ClienteId').value = '';
	document.getElementById('ClienteCpf').value = '';
	document.getElementById('ClienteNome').value = '';
	document.getElementById('finalizadocliente').checked = false;
	document.getElementById('excluidocliente').checked = false;
	document.getElementById('entidadecliente').selectedIndex = 0;

	return true;
}

function getIdade(input) {
	var today = new Date();
	//var birthdayDate = new Date(input);

	var array_date = input.split('/');
	var birthdayYear = parseInt(array_date[2]);
	var birthdayMonth = parseInt(array_date[1])-1;
	var birthdayDay = parseInt(array_date[0]);
	 
	var age = today.getFullYear() - birthdayYear;
	var month = today.getMonth() - birthdayMonth;
	
	//alert("entrada: "+today);
	
	if(month < 0 || (month == 0 & today.getDate() < birthdayDay)) {
		age = age - 1;
		//alert("dia atual: "+today.getMonth());
		//alert("dia nasc: "+birthdayMonth);
	}

	return age;
}

function checkallUfs(input) {
	
	var ufs = document.getElementsByClassName('checkEntidadeUfs');
	//alert("teste: "+ufs.length);
	
	var index = false;

	if(input.checked == true) {
		index = true;
	}

	for(var i = 0; i < ufs.length; i++) {
		ufs[i].childNodes[0].checked = index;	
	}
	
}

function uncheckallUfs() {
	//alert("teste");

	var ufs = document.getElementsByClassName('checkEntidadeUfs');

	for(var i = 0; i < ufs.length; i++) {
		if(ufs[i].childNodes[0].checked == false) {
			document.getElementById('checkallUfscheckbox').checked = false;
		}
	}
}

function checkallCorretores(input) {
	
	var corretores = document.getElementsByClassName('checkCorretoresOperadoras');
	//alert("teste: "+ufs.length);
	
	var index = false;

	if(input.checked == true) {
		index = true;
	}

	for(var i = 0; i < corretores.length; i++) {
		corretores[i].childNodes[0].checked = index;	
	}
	
}

function uncheckallCorretores() {
	//alert("teste");

	var corretores = document.getElementsByClassName('checkCorretoresOperadoras');

	for(var i = 0; i < corretores.length; i++) {
		if(corretores[i].childNodes[0].checked == false) {
			document.getElementById('checkallCorretorescheckbox').checked = false;
		}
	}
}

function onlyNumbers(evt) {
	var theEvent = evt || window.event;
	var key = theEvent.keyCode || theEvent.which;

	var keychar = String.fromCharCode(key);
	//alert(keychar);
	var keycheck =  /^[0-9_\b]+$/;  

	if(!(key == 8  ||  key == 27  || key == 46  || key == 37 || key == 39 ) ) {
		if ( !keycheck.test(keychar) ) {       
	        theEvent.returnValue = false;//for IE
		   	if (theEvent.preventDefault) {
			   	theEvent.preventDefault();//Firefox
		   	}
		}
	}  
}



</SCRIPT>
</html>
